#pragma once

#ifdef __QT5_TARGET

#include <QtCore/QMap>
#include <QtCore/QDate>
#include <QtCore/QDateTime>
#include <QtCore/QTime>
#include <QtCore/QList>

#else

#include <QMap>
#include <QDate>
#include <QDateTime>
#include <QTime>
#include <QList>

#endif

#include "Visit.h"
#include "Filter.h"
#include "korlapadmin_model_global.h"

class KORLAPADMIN_MODEL_EXPORT VisitManager
{
public:
	VisitManager(void);
	//void loadAllUnfinished();
	void loadLastVisit();
	void loadVisits(Filter* filter);
	QList<Visit*> getAllUnfinished();
	Visit* getLastVisit();
	Visit* getLastVisit(unsigned int patinet_id);
	Visit* getVisit(unsigned int visit_id);
	QList<Visit*> getVisits(int pos,int number);
	QList<Visit*> getVisits(QDate date);
	QList<Visit*> getVisits(QDate from, QDate to);
	QList<Visit*> getVisits(unsigned int patient_id);
	QList<Visit*> getVisits(Filter* filter);
	QList<Visit*> getFirstVisits();
	QList<Visit*> getFollowUps();
	QList<Visit*> getLastVisits();
	QList<Visit*> getNextVisits();
	QMap<QTime,Visit*>* getVisitByDayCache();
	void loadVisits(QDate date);
	void addVisit(Visit* visit);
	Visit* getNextVisit();
	Visit* getNextVisit(unsigned int patient_id);
	void deleteVisit(Visit * v);

	~VisitManager(void);
private:
	QMap<QDateTime,Visit*> * visits;
	QMap<QDateTime, Visit*>* unfinishedCache;
	QMap<QTime, Visit*>* visitsByDayCache;
	QMap<unsigned int,Visit*>* visitByIDCache;

};
